package day0513;

import java.util.Random;
import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        //1.生成两个随机整数num1和num2，再生成一个小于4随机整数ope
        Random r = new Random();
        int num1 = r.nextInt(100),  num2 = r.nextInt(100)+1,answer1=0;
        int ope = r.nextInt(4);
        String question="";
        //2.用switch-case判断ope等于几：
        switch (ope) {
            case 0:question = num1 + " + " + num2 + " = ";answer1=num1+num2;break;
            case 1:question = num1 + " - " + num2 + " = ";answer1=num1-num2;break;
            case 2:question = num1 + " * " + num2 + " = ";answer1=num1*num2;break;
            case 3:question = num1 + " / " + num2 + " = ";answer1=num1/num2;break;
        }
        System.out.print(question);
        //3.Scanner输入答案
        Scanner s = new Scanner(System.in);
        int answer2 =80000;
        while(answer1!=answer2) {
            answer2 = s.nextInt();
            //4.用三目运算符判断对错。
            System.out.println(answer1 == answer2 ? "回答正确" : "回答错误");
        }
    }
}
